/* handles shop values and prices */
class Shop {

	/* initialize */
	constructor() {

		/* data types */
		this.SPAWN_SPEED = 0;
		this.SPAWN_VALUE = 1;
		this.COLLECTORS  = 2;
		this.COLLECTOR_SPEED = 3;
		this.SPAWN_LIMIT = 4;

		/* counters of current levels */
		this.counters = [0, 0, 0, 0, 0];

		/* prices to buy levels */
		this.prices = [5, 15, 27, 41, 58, 70, 93, 120];

		/* actual data sorted like data types */
		this.data = [
			[120, 60, 35, 22, 15, 10, 9, 7, 6],
			[1, 2, 3, 5, 7, 10, 13, 16, 20],
			[0, 1, 2, 4, 6, 9, 13, 16, 20],
			[180, 168, 156, 138, 129, 120, 105, 90, 60],
			[10, 15, 20, 25, 30, 35, 40, 45, 50],
		];

	} /* constructor */

	/* return current level data,
	 * offset is used to display data of previous/next levels
	 * -1 is previous level, +1 is next level etc
	 */
	get_data(data_type, counter_offset = 0) {
		return this.data[data_type][
			this.counters[data_type]+counter_offset
		];
	}

	/* increase the level of specified data type
	 * in the case of collectors, return how many
	 * new collectors to create
	 */
	increase_data(data_type) {

		/* check for level limit */
		if (this.counters[data_type] < 8) {

			/* increase level */
			this.counters[data_type]++;

			/* return new collectors to create */
			if (data_type == this.COLLECTORS) {
				return this.get_data(this.COLLECTORS)
					-this.get_data(this.COLLECTORS, -1);
			}

		} /* level limit */

	} /* increase level */

	/* return the level itself of speified data type */
	get_counter(data_type) {
		return this.counters[data_type];
	}

	/* return cost of next level of data type */
	cost(data_type) {
		return this.prices[ this.counters[data_type] ];
	}

} /* shop */
